Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

243
Vistas
¿Hay "si .. no en .." en Javascript? Lo uso en Python pero no estoy seguro si Javascript tiene una sintaxis similar

Esta función debería eliminar las vocales en la cadena y devolver una cadena sin vocales.

 function removeVowels(string) { var newstring = ''; var vowels = ['a','e','i','o','u']; for ( i in string) { if ( i.toLowerCase() not in vowels) { // I know this is wrong but is anything I can use instead of "not in" in JS? continue } else { newstring += i } } return newstring; }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

JavaScript no tiene una palabra clave not . En cambio, tiene un ! para cuando quieras usar no. JS's in NO es lo mismo que python's in . JS lo usa para índices, y si desea el carácter en el índice, debe usar of .

También hice algunos ajustes menores aquí y allá, como no usar var y eliminar las declaraciones de continuación.

 function removeVowels(string) { // Instead of using var here, use let and const. let newString = ''; const vowels = ['a','e','i','o','u']; // Loop through every character of string for (const char of string) { // Instead of the continue that you used, you can just simply check if the vowels array includes the specific character. if (!vowels.includes(char.toLowerCase())) { // This just appends the character to the new string variable newString += char; } } return newString; } console.log(removeVowels('This string will not have any vowels in it.'));
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda